package com.moxiao.yfjh.module.blind.dal.mysql.memberSeeme;

import com.moxiao.yfjh.module.blind.controller.admin.memberSeeme.vo.MemberSeemeExportReqVO;
import com.moxiao.yfjh.module.blind.controller.admin.memberSeeme.vo.MemberSeemePageReqVO;
import com.moxiao.yfjh.module.blind.controller.app.controller.exchage.vo.AppMemberSeemeReqVO;
import com.moxiao.yfjh.module.blind.dal.dataobject.memberSeeme.MemberSeemeDO;
import java.util.*;

import com.moxiao.yfjh.framework.common.pojo.PageResult;
import com.moxiao.yfjh.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.moxiao.yfjh.framework.mybatis.core.mapper.BaseMapperX;
import org.apache.ibatis.annotations.Mapper;
import com.moxiao.yfjh.module.blind.controller.admin.memberSeeme.vo.*;

/**
 * 相亲会员看过我 Mapper
 *
 * @author mx
 */
@Mapper
public interface MemberSeemeMapper extends BaseMapperX<MemberSeemeDO> {

    default PageResult<MemberSeemeDO> selectPage(MemberSeemePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MemberSeemeDO>()
                .eqIfPresent(MemberSeemeDO::getUserId, reqVO.getUserId())
                .eqIfPresent(MemberSeemeDO::getIssue, reqVO.getIssue())
                .eqIfPresent(MemberSeemeDO::getReceive, reqVO.getReceive())
                .eqIfPresent(MemberSeemeDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(MemberSeemeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MemberSeemeDO::getId));
    }

    default List<MemberSeemeDO> selectList(MemberSeemeExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<MemberSeemeDO>()
                .eqIfPresent(MemberSeemeDO::getUserId, reqVO.getUserId())
                .eqIfPresent(MemberSeemeDO::getIssue, reqVO.getIssue())
                .eqIfPresent(MemberSeemeDO::getReceive, reqVO.getReceive())
                .eqIfPresent(MemberSeemeDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(MemberSeemeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MemberSeemeDO::getId));
    }



    default List<MemberSeemeDO> selectSeeMeList(AppMemberSeemeReqVO reqVO) {
        LambdaQueryWrapperX<MemberSeemeDO> memberSeemeDOLambdaQueryWrapperX = new LambdaQueryWrapperX<MemberSeemeDO>()
                .eqIfPresent(MemberSeemeDO::getUserId, reqVO.getUserId())
                .eqIfPresent(MemberSeemeDO::getIssue, reqVO.getIssue())
                .eqIfPresent(MemberSeemeDO::getReceive, reqVO.getReceive())
                .eqIfPresent(MemberSeemeDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(MemberSeemeDO::getCreateTime, reqVO.getCreateTime());
        if (Objects.equals(reqVO.getHaveMember(),1)){
            memberSeemeDOLambdaQueryWrapperX.orderByDesc(MemberSeemeDO::getId);
        }else {
            memberSeemeDOLambdaQueryWrapperX.orderByAsc(MemberSeemeDO::getId);
        }
        return selectList(memberSeemeDOLambdaQueryWrapperX);
    }

}
